/*     */ package com.yc.web;
/*     */ 
/*     */ import com.yc.dao.model.RolesBO;
/*     */ import com.yc.dao.model.SysmMenuBO;
/*     */ import com.yc.dao.model.UserBO;
/*     */ import com.yc.service.SystemService;
/*     */ import com.yc.util.ExtTreeNode;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.HashSet;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class SystemWeb
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(SystemWeb.class);
/*  23 */   private SystemService systemService = null;
/*     */ 
/*     */   public SystemWeb()
/*     */   {
/*  27 */     this.systemService = new SystemService();
/*     */   }
/*     */ 
/*     */   public boolean createMenu(SysmMenuBO bo, String strOldParentMenuId)
/*     */   {
/*  32 */     String strMenuID = bo.getID();
/*  33 */     if ((strMenuID == null) || ("".endsWith(strMenuID.trim())))
/*     */     {
/*  35 */       strMenuID = this.systemService.queryMaxMenuID("Menu");
/*  36 */       bo.setID(strMenuID);
/*  37 */       return this.systemService.createMenu(bo);
/*     */     }
/*     */ 
/*  40 */     return this.systemService.updateMenu(bo, strOldParentMenuId);
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] findMenuTree(String strMenuID, Map params)
/*     */   {
/*  53 */     log.info(" 根据菜单ID 查询该该菜单的子菜单 findMenuTree():  strMenuID = [" + strMenuID + "]");
/*  54 */     if ((strMenuID != null) && (!"".equals(strMenuID.trim())))
/*  55 */       strMenuID = strMenuID.trim();
/*     */     else
/*  57 */       strMenuID = "0";
/*  58 */     List menuList = new ArrayList();
/*     */ 
/*  60 */     List list = getSubMenuTreeByMenuID(strMenuID);
/*  61 */     if ((list != null) && (list.size() > 0))
/*     */     {
/*  63 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/*  65 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/*  66 */         SysmMenuBO bo = (SysmMenuBO)list.get(i);
/*  67 */         extTreeNode.setId(bo.getID());
/*  68 */         extTreeNode.setText(bo.getNAME());
/*  69 */         extTreeNode.setDisabled(false);
/*  70 */         extTreeNode.setAllowDrag(false);
/*     */ 
/*  72 */         if ("true".equals(bo.getLEAF_FLAG()))
/*  73 */           extTreeNode.setLeaf(true);
/*     */         else
/*  75 */           extTreeNode.setLeaf(false);
/*  76 */         menuList.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  81 */     ExtTreeNode[] treeNode = new ExtTreeNode[menuList.size()];
/*  82 */     menuList.toArray(treeNode);
/*  83 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] getMenuTreeForAuth(String strMenuID, Map params)
/*     */   {
/*  95 */     log.info(" 根据菜单ID 查询该该菜单的子菜单 getMenuTreeForAuth():  strMenuID = [" + strMenuID + "]");
/*  96 */     if ((strMenuID != null) && (!"".equals(strMenuID.trim())))
/*  97 */       strMenuID = strMenuID.trim();
/*     */     else {
/*  99 */       strMenuID = "0";
/*     */     }
/* 101 */     Set menuSet = new HashSet();
/* 102 */     Object objRoleID = params.get("ROLE_ID");
/*     */     String strRoleID;
/* 104 */     if (objRoleID != null)
/* 105 */       strRoleID = objRoleID.toString().trim();
/*     */     else
/* 107 */       strRoleID = "";
/* 108 */     List choosedMenuIDS = this.systemService.getMenuIdByRoleID(strRoleID);
/* 109 */     if ((choosedMenuIDS != null) && (choosedMenuIDS.size() != 0))
/*     */     {
/* 111 */       for (int i = 0; i < choosedMenuIDS.size(); i++)
/*     */       {
/* 113 */         if (!menuSet.contains(choosedMenuIDS.get(i))) {
/* 114 */           menuSet.add(choosedMenuIDS.get(i));
/*     */         }
/*     */       }
/*     */     }
/* 118 */     List menuList = new ArrayList();
/* 119 */     List list = getSubMenuTreeByMenuID(strMenuID);
/* 120 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 122 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 124 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/* 125 */         SysmMenuBO bo = (SysmMenuBO)list.get(i);
/* 126 */         extTreeNode.setId(bo.getID());
/* 127 */         extTreeNode.setText(bo.getNAME());
/* 128 */         extTreeNode.setDisabled(false);
/* 129 */         extTreeNode.setAllowDrag(false);
/* 130 */         extTreeNode.setChecked(Boolean.FALSE);
/* 131 */         if ("true".equals(bo.getLEAF_FLAG()))
/* 132 */           extTreeNode.setLeaf(true);
/*     */         else
/* 134 */           extTreeNode.setLeaf(false);
/* 135 */         if (menuSet.contains(bo.getID()))
/* 136 */           extTreeNode.setChecked(Boolean.TRUE);
/*     */         else
/* 138 */           extTreeNode.setChecked(Boolean.FALSE);
/* 139 */         menuList.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 144 */     ExtTreeNode[] treeNode = new ExtTreeNode[menuList.size()];
/* 145 */     menuList.toArray(treeNode);
/* 146 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] findMenuTreeByParentID(String strRoleID)
/*     */   {
/* 152 */     log.info(" 根据角色ID 查询该角色的菜单权限 strRoleID = [" + strRoleID + "]");
/* 153 */     if ((strRoleID != null) && (!"".equals(strRoleID.trim())))
/* 154 */       strRoleID = strRoleID.trim();
/*     */     else
/* 156 */       strRoleID = "0";
/* 157 */     Set menuSet = new HashSet();
/* 158 */     List choosedMenuIDS = this.systemService.getMenuIdByRoleID(strRoleID);
/* 159 */     if ((choosedMenuIDS != null) && (choosedMenuIDS.size() != 0))
/*     */     {
/* 161 */       for (int i = 0; i < choosedMenuIDS.size(); i++)
/*     */       {
/* 163 */         if (!menuSet.contains(choosedMenuIDS.get(i))) {
/* 164 */           menuSet.add(choosedMenuIDS.get(i));
/*     */         }
/*     */       }
/*     */     }
/* 168 */     List menuList = new ArrayList();
/* 169 */     List list = getSubMenuTreeByMenuID("0");
/* 170 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 172 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 174 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/* 175 */         SysmMenuBO bo = (SysmMenuBO)list.get(i);
/* 176 */         extTreeNode.setId(bo.getID());
/* 177 */         extTreeNode.setText(bo.getNAME());
/* 178 */         extTreeNode.setDisabled(false);
/* 179 */         extTreeNode.setAllowDrag(false);
/* 180 */         if ("true".equals(bo.getLEAF_FLAG()))
/* 181 */           extTreeNode.setLeaf(true);
/*     */         else
/* 183 */           extTreeNode.setLeaf(false);
/* 184 */         if (menuSet.contains(bo.getID()))
/* 185 */           extTreeNode.setChecked(Boolean.TRUE);
/*     */         else {
/* 187 */           extTreeNode.setChecked(Boolean.FALSE);
/*     */         }
/* 189 */         menuList.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 194 */     ExtTreeNode[] treeNode = new ExtTreeNode[menuList.size()];
/* 195 */     menuList.toArray(treeNode);
/* 196 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] getParentMenuTree(String strMenuID, Map params)
/*     */   {
/* 206 */     log.info(" 根据菜单ID 查询该该菜单的子菜单  getParentMenuTree(): strMenuID = [" + strMenuID + "]");
/* 207 */     if ((strMenuID != null) && (!"".equals(strMenuID.trim())))
/* 208 */       strMenuID = strMenuID.trim();
/*     */     else
/* 210 */       strMenuID = "0";
/* 211 */     String strEditMenuId = params.get("strEditMenuId").toString();
/* 212 */     List menuList = new ArrayList();
/* 213 */     List list = this.systemService.getParentMenuTree(strMenuID, strEditMenuId);
/* 214 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 216 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 218 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/* 219 */         SysmMenuBO bo = (SysmMenuBO)list.get(i);
/* 220 */         extTreeNode.setId(bo.getID());
/* 221 */         extTreeNode.setText(bo.getNAME());
/* 222 */         extTreeNode.setDisabled(false);
/* 223 */         extTreeNode.setAllowDrag(false);
/*     */ 
/* 227 */         extTreeNode.setLeaf(true);
/*     */ 
/* 229 */         menuList.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 234 */     ExtTreeNode[] treeNode = new ExtTreeNode[menuList.size()];
/* 235 */     menuList.toArray(treeNode);
/* 236 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public List getSubMenuTreeByMenuID(String strMenuID)
/*     */   {
/* 248 */     return this.systemService.getSubMenuTreeByMenuID(strMenuID);
/*     */   }
/*     */ 
/*     */   public boolean deleteMenyByID(String strMenuId, String strParentMenuID)
/*     */   {
/* 253 */     return this.systemService.deleteMenyByID(strMenuId, strParentMenuID);
/*     */   }
/*     */ 
/*     */   public SysmMenuBO getMenuInfoByID(String strMenuID)
/*     */   {
/* 261 */     return this.systemService.getMenuInfoByID(strMenuID);
/*     */   }
/*     */ 
/*     */   public boolean createRoles(RolesBO bo)
/*     */   {
/* 266 */     if ((bo.getId() == null) || ("".equalsIgnoreCase(bo.getId().trim()))) {
/* 267 */       String strRolesID = this.systemService.queryMaxMenuID("Role");
/* 268 */       bo.setId(strRolesID);
/* 269 */       return this.systemService.createRoles(bo);
/*     */     }
/* 271 */     return this.systemService.updateRoles(bo);
/*     */   }
/*     */ 
/*     */   public boolean updateRoles(RolesBO bo) {
/* 275 */     return this.systemService.updateRoles(bo);
/*     */   }
/*     */ 
/*     */   public boolean deleteRoles(String strID) {
/* 279 */     return this.systemService.deleteRoles(strID);
/*     */   }
/*     */ 
/*     */   public RolesBO getRolesInforByID(String strID)
/*     */   {
/* 284 */     return this.systemService.getRolesInforByID(strID);
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getRolesList(Map condition) {
/* 288 */     return this.systemService.getRolesList(condition);
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] findRoleTree(String strRolID, Map params)
/*     */   {
/* 294 */     List listRoleTree = new ArrayList();
/* 295 */     List list = this.systemService.getRolesList();
/* 296 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 298 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 300 */         RolesBO bo = (RolesBO)list.get(i);
/* 301 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/* 302 */         extTreeNode.setId(bo.getId());
/* 303 */         extTreeNode.setText(bo.getNAME());
/* 304 */         extTreeNode.setDisabled(false);
/* 305 */         extTreeNode.setAllowDrag(false);
/* 306 */         extTreeNode.setLeaf(true);
/* 307 */         listRoleTree.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 312 */     ExtTreeNode[] treeNode = new ExtTreeNode[listRoleTree.size()];
/* 313 */     listRoleTree.toArray(treeNode);
/* 314 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public boolean save(String selectedItem, String role_id)
/*     */   {
/* 329 */     return this.systemService.save(selectedItem, role_id);
/*     */   }
/*     */ 
/*     */   public Map getRolesForOptions()
/*     */   {
/* 334 */     Map map = new HashMap();
/* 335 */     List list = this.systemService.getRolesList();
/* 336 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 338 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 340 */         RolesBO bo = (RolesBO)list.get(i);
/* 341 */         map.put(bo.getId(), bo.getNAME());
/*     */       }
/*     */     }
/* 344 */     return map;
/*     */   }
/*     */   public String[][] getComboArrayForRoles() {
/* 347 */     String[][] roleData = (String[][])null;
/* 348 */     List list = this.systemService.getRolesList();
/* 349 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 351 */       roleData = new String[list.size()][2];
/* 352 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 354 */         RolesBO bo = (RolesBO)list.get(i);
/* 355 */         roleData[i] =new String[] { bo.getId().toString(), bo.getNAME().toString() };
/*     */       }
/*     */     }
/* 358 */     return roleData;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getUserList(Map condition)
/*     */   {
/* 363 */     return this.systemService.getUserList(condition);
/*     */   }
/*     */   public boolean createUser(UserBO bo) {
/* 366 */     String strUserId = bo.getId();
/* 367 */     if ((strUserId == null) || ("".equalsIgnoreCase(strUserId.trim())))
/*     */     {
/* 369 */       strUserId = this.systemService.queryMaxMenuID("User");
/* 370 */       bo.setId(strUserId);
/* 371 */       return this.systemService.createUser(bo);
/*     */     }
/* 373 */     return this.systemService.updateUser(bo);
/*     */   }
/*     */ 
/*     */   public boolean deleteUser(String strID)
/*     */   {
/* 379 */     return this.systemService.deleteUser(strID);
/*     */   }
/*     */ 
/*     */   public UserBO getUserById(String strID) {
/* 383 */     return this.systemService.getUserById(strID);
/*     */   }
/*     */   public boolean disableUser(String strID) {
/* 386 */     return this.systemService.disableOrEnableUser(strID, "0");
/*     */   }
/*     */ 
/*     */   public boolean EnableUser(String strID) {
/* 390 */     return this.systemService.disableOrEnableUser(strID, "1");
/*     */   }
/*     */   public boolean updatePassword(String strUserID, String strPasswd) {
/* 393 */     return this.systemService.updatePassword(strUserID, strPasswd);
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getUserListByRoleID(Map condition) {
/* 397 */     return this.systemService.getUserListByRoleID(condition);
/*     */   }
/*     */   public boolean updateUserRole(String strUserId, String strRoleId) {
/* 400 */     return this.systemService.updateUserRole(strUserId, strRoleId);
/*     */   }
/*     */ 
/*     */   public ExtTreeNode[] getUserListForRoles(String strRolID, Map params)
/*     */   {
/* 405 */     List listUserTree = new ArrayList();
/* 406 */     List list = this.systemService.getUserListForRoles();
/* 407 */     if ((list != null) && (list.size() > 0))
/*     */     {
/* 409 */       for (int i = 0; i < list.size(); i++)
/*     */       {
/* 411 */         UserBO bo = (UserBO)list.get(i);
/* 412 */         ExtTreeNode extTreeNode = new ExtTreeNode();
/* 413 */         extTreeNode.setId(bo.getId());
/* 414 */         extTreeNode.setText(bo.getUsername());
/* 415 */         extTreeNode.setDisabled(false);
/* 416 */         extTreeNode.setAllowDrag(false);
/* 417 */         extTreeNode.setLeaf(true);
/* 418 */         extTreeNode.setChecked(Boolean.FALSE);
/* 419 */         listUserTree.add(extTreeNode);
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/* 424 */     ExtTreeNode[] treeNode = new ExtTreeNode[listUserTree.size()];
/* 425 */     listUserTree.toArray(treeNode);
/* 426 */     return treeNode;
/*     */   }
/*     */ 
/*     */   public boolean deleteUserFromRole(String strUserId, String strRoleId) {
/* 430 */     return this.systemService.deleteUserFromRole(strUserId, strRoleId);
/*     */   }
/*     */   public boolean addUserFromRole(String strUserId, String strRoleId) {
/* 433 */     return this.systemService.addUserFromRole(strUserId, strRoleId);
/*     */   }
/*     */ 
/*     */   public boolean isAvialable(String strUserName, String strOldPassword, boolean isID) {
/* 437 */     return this.systemService.isAvialable(strUserName, strOldPassword, isID);
/*     */   }
/*     */ 
/*     */   public String getRoleByUserID(String strUserID) {
/* 441 */     return this.systemService.getRoleByUserID(strUserID);
/*     */   }
/*     */ 
/*     */   public boolean updateUserBySelf(UserBO bo) {
/* 445 */     return this.systemService.updateUserBySelf(bo);
/*     */   }
/*     */ 
/*     */   public UserBO getUserByName(String strName) {
/* 449 */     return this.systemService.getUserByName(strName);
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.web.SystemWeb
 * JD-Core Version:    0.6.2
 */